<style>
    #notice-add {
        padding: 20px 25px 25px 0;
    }
</style>
<div class="layui-fluid" id="notice-add">
    <form class="layui-form" action="" lay-filter="notice-add-form">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label ">通知图片</label>
            <div class="layui-upload">
                <div class="layui-upload-list">
                    <img class="layui-upload-img"  id="notice-add-img1"  src="/febs/images/defaultImg.png" width="35%" style="vertical-align: bottom">
                    <a onclick="getElementById('notice-add-img1').click()">上传图片</a>
                    <input type="hidden" id="myimg" name="imgUrl">
                    <p id="demoText"></p>
                </div>
                <span style="padding-left: 110px;font-size: 13px;">（上传的图片尺寸应小于750*560）</span>
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label febs-form-item-require">通知标题</label>
            <div class="layui-input-block">
                <input type="text" name="title"  minlength="2" maxlength="50"
                       autocomplete="off" class="layui-input" lay-verify="required|txt">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">公司名</label>
            <div class="layui-input-block">
                <input type="text" data-th-value="陕西全务"
                       autocomplete="off" class="layui-input" readonly="true">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">创建人</label>
            <div class="layui-input-block">
                <input type="text" name="UserName" data-th-value="${username}"
                       autocomplete="off" class="layui-input" readonly="true">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">创建日期</label>
            <div class="layui-input-block">
                <input type="text" disabled="true"
                       autocomplete="off" class="layui-input" id="currentTime" readonly="true">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label febs-form-item-require">通知内容</label>
            <div class="layui-input-block">
                <textarea name="content" maxlength="100" class="layui-textarea" lay-verify="required|txt"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div>
                <label class="layui-form-label">通知视频</label>
                <div class="layui-upload">
                    <div class="layui-upload-list" width="100%">
                        <video class="layui-upload-video" src="" id="videoPlay" controls="controls" style="vertical-align: bottom;width: 35%" hidden="true">
                        </video>
                        <a onclick="getElementById('fileUpload').click()" style="margin-right: 10px;height: 38px;line-height: 38px;margin-left: 4px;">
                            请选择视频
                            <input type="file" hidden="hidden" id="fileUpload">
                        </a>
                        <input type="hidden" id="videoId">
                        <a id="authUpload"  disabled="true" style="margin-right: 10px" hidden="true">开始上传</a>
                        <a id="pauseUpload"  disabled="true" style="margin-right: 10px" hidden="true">暂停</a>
                        <a id="resumeUpload"  disabled="true" hidden="true">恢复上传</a>
                        <div class="layui-progress" hidden="hidden"  id="videoProgress" style="margin-left: 110px" lay-filter="videoProgress" lay-showPercent="true" >
                            <div class="layui-progress-bar" lay-percent="0%"  style="width: 0%"></div>
                        </div>
                        <input type="hidden" id="notice-add-myvideo" name="videoUrl">
                        <p id="videoText"></p >
                        <label class="status" style="margin-left: 110px;margin-top: 10px"><span id="status"></span></label>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">通知附件</label>
            <div class="layui-upload">
                <div class="layui-upload-list">
                    <file class="layui-upload-file" src="" id="notice-add-file1" width="200px" height="150px"></file>
                    <input type="hidden" id="notice-add-myfile" name="myfile">
                    <p id="fileText"></p>
                </div>
                    <a id="showFile" hidden="true"><i class="layui-icon layui-icon-filedone" title="查看附件">查看附件</i></a>
                <a id="notice-add-testfile">上传附件</a>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md10">
                <div class="layui-form-item">
                    <label class="layui-form-label febs-form-item-require">接收人</label>
                    <div class="layui-input-block">
                        <textarea id="noticereceive" autocomplete="off"
                                  class="layui-textarea" lay-verify="required" readonly="true"></textarea>
                    </div>
                </div>
            </div>
            <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
                <!--出现一个加号-->
                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="student"
                     style="margin-left: 10px" title="添加">
                    <i class="layui-icon">&#xe624;</i>
                </div>
                <!--出现一个减号-->
                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action"
                     id="resetUser" title="清除">
                    <i class="layui-icon">&#xe67e;</i>
                </div>

            </div>
        </div>

        <!--隐藏的部分属性-->
        <div class="layui-form-item febs-hide">
            <label class="layui-form-label febs-form-item-require">接收人隐藏id</label>
            <div class="layui-input-block">
                <input type="text" name="userIdss" id="noticereceivehide">
            </div>
        </div>

        <div class="layui-form-item febs-hide">
            <label class="layui-form-label febs-form-item-require">创建人id</label>
            <div class="layui-input-block">
                <input type="text" name="createUserId" data-th-value="${userId}">
            </div>
        </div>

        <div class="layui-form-item febs-hide">
            <label class="layui-form-label febs-form-item-require febs-hide">消息提交状态</label>
            <div class="layui-input-block">
                <input type="text" name="status" id="status_Id">
            </div>
        </div>
        <div class="layui-form-item febs-hide">
            <button class="layui-btn" lay-submit="" lay-filter="notice-add-form-submit" id="submit"></button>
            <button class="layui-btn" lay-submit="" lay-filter="notice-add-form-submitTemp" id="submitTemp"></button>
            <button type="reset" class="layui-btn" id="reset"></button>
        </div>
    </form>
</div>

<script>
    layui.use(['febs', 'form', 'xmSelect', 'validate', 'laydate', 'dropdown', 'jquery', 'table', 'upload'], function () {
        let $ = layui.$,
            febs = layui.febs,
            layer = layui.layer,
            form = layui.form,
            laydate = layui.laydate,
            upload = layui.upload,
            $view = $('#notice-add'),
            $student = $view.find('#student'),
            $resetUser = $view.find('#resetUser'),
            validate = layui.validate;
        let lock = false;

        form.verify(validate);
        form.render();

        laydate.render({
            elem: '#currentTime',
            type: 'datetime',
            value: new Date(),
            done: function (value, date) {
            }
            ,btns: ['clear', 'confirm']
        });
        // 图片上传
        const uploadInst = upload.render({
            elem: '#notice-add-img1'
            , url: ctx + 'upload' //改成您自己的上传接口
            , method: 'post'
            , auto: false
            , accept: 'images'
            , exts: 'jpg|png|gif|bmp|jpeg'
            , choose: function (obj) {
                //预读本地文件示例，不支持ie8
                let flag = true;
                obj.preview(function (index, file, result) {
                    const img = new Image();
                    img.src = result;
                    img.onload = function () { //初始化夹在完成后获取上传图片宽高，判断限制上传图片的大小。
                        if (img.width <= 750 && img.height <= 560) {
                            $('#notice-add-img1').attr('src', result); //图片链接（base64）
                            obj.upload(index, file); //满足条件调用上传方法
                        } else {
                            flag = false;
                            layer.msg("您上传的图片尺寸必须小于750*560尺寸！");
                            return false;
                        }
                    }
                    return flag;
                });
            }
            , done: function (res) {
                // 上传成功
                if (res.code === 200) {
                    layer.msg('上传图片成功');
                    $("#myimg").val(res.url);
                }
            }
            , error: function () {
                // 示失败状态，并实现重传
                const demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        //附件上传
        const uploadFile = upload.render({
            elem: '#notice-add-testfile'
            , url: ctx + 'upload' //改成您自己的上传接口
            , method: 'post'
            , auto: false
            , accept: 'file'
            , exts: 'mp4|avi|jpg|png|gif|bmp|jpeg|doc|docx|txt|xls|xlsx|pdf|rar|zip'
            , choose: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#notice-add-file1').attr('src', result);
                    obj.upload(index, file);
                });
            }
            , done: function (res) {
                //上传成功
                if (res.code === 200) {
                    $("#notice-add-myfile").val(res.url);
                    $('#showFile').attr("hidden",false);
                    layer.msg('上传附件成功');
                }
            }
            , error: function () {
                //演示失败状态，并实现重传
                const demoText = $('#fileText');
                demoText.html('<span style="color: #FF5722;">上传附件失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadFile.upload();
                });
            }
        });

        let stu_id = [];
        let stu_stuname = new Set();
        //进入学生的页面跳转控制器
        $student.on('click', function () {
            let selectStudent = febs.modal.open('选择学生', 'student/list', {
                area: ['100%', '100%'],
                btn: ['选择勾选结果', '选择本页结果', '选择全部结果'],
                yes: function (index, layero) {
                    if (!lock) {
                        lock = true;
                        let temporary;

                        $('#select-student').find('#btnCheckResults').trigger('click');

                        temporary=$('#select-student').find('#stu_stunames').val();
                        if(temporary.length > 0)
                        {
                            console.log("youxinxi")
                            let strings = temporary.split(",");
                            for(let i=0; i<strings.length; i++){
                                stu_stuname.add(strings[i]);
                            }
                            let tabval = $('#select-student').find('#selectStudentByTable').val();
                            let stuId;
                            if (tabval == 1){
                                stuId = {"1":$('#select-student').find('#stu_ids').val()};
                            }else if (tabval == 2){
                                stuId = {"2":$('#select-student').find('#stu_ids').val()};
                            }

                            // var json = $.toJSON(stuId);
                            var json = JSON.stringify(stuId)

                            //放入数组name
                            stu_id.push(json);//放入数组id
                            let tempArray=[];
                            stu_stuname.forEach(function (element, sameElement, set) {
                                tempArray.push(element);
                            });
                            //绑定显示name
                            $("#noticereceive").val(tempArray);
                            //绑定显示id
                            $("#noticereceivehide").val(stu_id);

                            setTimeout(function () {
                                lock = false;

                            }, 1000);


                        }else
                        {
                            setTimeout(function () {
                                console.log("meixinxi");
                                lock = false;

                            }, 1000);
                        }


                    }

                },
                btn2: function (index, layero) {
                    if (!lock) {
                        lock = true;
                        let temporary;
                        $('#select-student').find('#btnPageResults').trigger('click');

                        temporary =($('#select-student').find('#stu_stunames').val());//放入数组name
                        let strings = temporary.split(",");
                        for(let i=0; i<strings.length; i++){
                            stu_stuname.add(strings[i]);
                        }

                        let tabval = $('#select-student').find('#selectStudentByTable').val();
                        let stuId;
                        if (tabval == 1){
                            stuId = {"1":$('#select-student').find('#stu_ids').val()};
                        }else if (tabval == 2){
                            stuId = {"2":$('#select-student').find('#stu_ids').val()};
                        }

                        // var json = $.toJSON(stuId);
                        var json = JSON.stringify(stuId)
                        //放入数组name
                        stu_id.push(json);//放入数组id
                        console.log(stu_id);
                        let tempArray=[];
                        stu_stuname.forEach(function (element, sameElement, set) {
                            tempArray.push(element);
                        });
                        //绑定显示name
                        $("#noticereceive").val(tempArray);
                        //绑定显示id
                        $("#noticereceivehide").val(stu_id);
                        setTimeout(function () {
                            lock = false;
                        }, 1000);
                    }
                },
                btn3: function (index, layero) {
                    if (!lock) {
                        lock = true;
                        let temporary;
                        $('#select-student').find('#btnGetAllInofo').trigger('click');

                        let tabval = $('#select-student').find('#hidtabval').val();
                        // console.log("tabval:",tabval)

                        $.ajax({
                            type: 'get',
                            url: 'student/selectStudent?tabVal='+ $("#selectStudentByTable").val(),
                            cache: false,
                            traditional: true,
                            data: tabval,
                            success: function (res) {
                                let all_id = [];//存id
                                let all_stuName = [];//存stuName
                                if (res.data.length > 0) {
                                    for (let i = 0; i < res.data.length; i++) {
                                        let add = res.data[i];
                                        all_id.push(add.id)
                                        all_stuName.push(add.stuName);
                                    }
                                    // console.log("all_id",all_id)
                                    // $("#stu_stunames").val(all_stuName);
                                    // $("#stu_ids").val(all_id);
                                    // console.log("44444");
                                    // console.log("all_stuName:",all_stuName);
                                    temporary =all_stuName;//放入数组name
                                    let strings = temporary.toString().split(",");
                                    for(let i=0; i<strings.length; i++){
                                        stu_stuname.add(strings[i]);
                                    }

                                    let tempArray=[];
                                    stu_stuname.forEach(function (element, sameElement, set) {
                                        tempArray.push(element);
                                    });
                                    // var ball_idString = all_id.toString();
                                    // console.log("ball_idString:",ball_idString);
                                    // let tabval = tabval.split("&")[0].toString().charAt(tabval.split("&")[0].toString().length-1);
                                    let stuId;
                                    if (tabval == 1){
                                        stuId = {"1":all_id.toString()};
                                    }else if (tabval == 2){
                                        stuId = {"2":all_id.toString()};
                                    }
                                    // console.log("tabval:",tabval)
                                    // console.log("stuId:",stuId)
                                    // var json = $.toJSON(stuId);
                                    var json = JSON.stringify(stuId)
                                    // console.log("json:",json)
                                    //放入数组name
                                    stu_id.push(json);//放入数组id
                                    // console.log("stu_id:",stu_id);
                                    //绑定显示name
                                    $("#noticereceive").val(tempArray);
                                    //绑定显示id
                                    $("#noticereceivehide").val(stu_id);
                                    setTimeout(function () {
                                        lock = false;
                                    }, 1000);
                                }
                            }
                        });

                        // console.log("5555");
                        // temporary =($('#select-student').find('#stu_stunames').val());//放入数组name
                        // let strings = temporary.split(",");
                        // for(let i=0; i<strings.length; i++){
                        //     stu_stuname.add(strings[i]);
                        // }
                        //
                        // let tempArray=[];
                        // stu_stuname.forEach(function (element, sameElement, set) {
                        //     tempArray.push(element);
                        // });
                        //
                        // let tabval = $('#select-student').find('#selectStudentByTable').val();
                        // let stuId;
                        // if (tabval == 1){
                        //     stuId = {"1":$('#select-student').find('#stu_ids').val()};
                        // }else if (tabval == 2){
                        //     stuId = {"2":$('#select-student').find('#stu_ids').val()};
                        // }
                        //
                        // // var json = $.toJSON(stuId);
                        // var json = JSON.stringify(stuId)
                        // //放入数组name
                        // stu_id.push(json);//放入数组id
                        // console.log(stu_id);
                        // //绑定显示name
                        // $("#noticereceive").val(tempArray);
                        // //绑定显示id
                        // $("#noticereceivehide").val(stu_id);
                        // setTimeout(function () {
                        //     lock = false;
                        // }, 1000);
                    }
                },
                success: function (layero) {
                    layero.find('.layui-layer-btn').css('text-align', 'center');
                },
            });

        });

        form.on('submit(notice-add-form-submit)', function (data) {
            data.field.title=HTMLEncode(data.field.title);
            data.field.content=HTMLEncode(data.field.content);
            if (!lock) {
                lock = true;
                febs.post(ctx + 'notice/add', data.field, function () {
                    layer.closeAll();
                    febs.alert.success('新增通知成功');
                    $('#notice-list').find('#btnSearch').click();
                });
                setTimeout(function () {
                    lock = false;
                }, 2000);
            }
            return false;
        });

        form.on('submit(notice-add-form-submitTemp)', function (data) {
            data.field.title=HTMLEncode(data.field.title);
            data.field.content=HTMLEncode(data.field.content);
            if (!lock) {
                lock = true;
                febs.post(ctx + 'notice/addTemp', data.field, function () {
                    layer.closeAll();
                    febs.alert.success('保存草稿成功');
                    $('#notice-list').find('#btnSearch').click();
                });
                setTimeout(function () {
                    lock = false;
                }, 2000);
            }
            return false;
        });
        //清空
        $resetUser.on('click', function () {
            document.getElementById("noticereceive").value = "";
            //全局的数组一把清除
            stu_id.splice(0);
            stu_stuname= new Set();
        })

        //文本框内容转义
        function HTMLEncode(html) {
            let temp = document.createElement("div");
            (temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
            let output = temp.innerHTML;
            temp = null;
            return output;
        }

        //文本框内容反转义
        function HTMLDecode(text) {
            let temp = document.createElement("div");
            temp.innerHTML = text;
            let output = temp.innerText || temp.textContent;
            temp = null;
            return output;
        }

        //视频上传
        if (!FileReader.prototype.readAsBinaryString) {
            FileReader.prototype.readAsBinaryString = function (fileData) {
                let binary = "";
                let pt = this;
                let reader = new FileReader();
                reader.onload = function (e) {
                    let bytes = new Uint8Array(reader.result);
                    let length = bytes.byteLength;
                    for (let i = 0; i < length; i++) {
                        binary += String.fromCharCode(bytes[i]);
                    }
                    //pt.result  - readonly so assign binary
                    pt.content = binary;
                    pt.onload()
                }
                reader.readAsArrayBuffer(fileData);
            }
        }
        $(document).ready(function () {
            /**
             * 创建一个上传对象
             * 使用 UploadAuth 上传方式
             */
            function createUploader () {
                let uploader = new AliyunUpload.Vod({
                    timeout: 60000,
                    partSize: 10485760,
                    parallel: 2,
                    retryCount: 3,
                    retryDuration: 2,
                    region: "cn-shanghai",
                    userId: "1592141428197506",
                    // 添加文件成功
                    addFileSuccess: function (uploadInfo) {
                        $('#authUpload').attr('disabled', false)
                        $('#resumeUpload').attr('disabled', false)
                        $('#status').text('添加文件成功, 等待上传...')
                    },
                    // 开始上传
                    onUploadstarted: function (uploadInfo) {
                        // 如果是 UploadAuth 上传方式, 需要调用 uploader.setUploadAuthAndAddress 方法
                        // 如果是 UploadAuth 上传方式, 需要根据 uploadInfo.videoId是否有值，调用点播的不同接口获取uploadauth和uploadAddress
                        // 如果 uploadInfo.videoId 有值，调用刷新视频上传凭证接口，否则调用创建视频上传凭证接口
                        // 注意: 这里是测试 demo 所以直接调用了获取 UploadAuth 的测试接口, 用户在使用时需要判断 uploadInfo.videoId 存在与否从而调用 openApi
                        // 如果 uploadInfo.videoId 存在, 调用 刷新视频上传凭证接口(https://help.aliyun.com/document_detail/55408.html)
                        // 如果 uploadInfo.videoId 不存在,调用 获取视频上传地址和凭证接口(https://help.aliyun.com/document_detail/55407.html)
                        if(uploadInfo.videoId){
                            let refreshUrl =  '/refreshAuth?videoId=' + uploadInfo.videoId
                            $.get(refreshUrl, function (data) {
                                uploader.setUploadAuthAndAddress(uploadInfo, data.uploadAuth, data.uploadAddress);
                            }, 'json')
                        }else {
                            let createUrl =  '/getAuth?title='+ title +'&suffix='+ suffix;
                            $.get(createUrl, function (data) {
                                let uploadAuth = data.uploadAuth
                                let uploadAddress = data.uploadAddress
                                let videoId = data.videoId

                                $("#videoId").val(videoId);

                                uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress,videoId)
                            }, 'json')
                            $('#status').text('准备中...')
                        }
                    },
                    // 文件上传成功
                    onUploadSucceed: function (uploadInfo) {
                        $('#status').text('文件上传成功!')
                        $("#videoProgress").attr('hidden','hidden');
                        $("#videoPlay").attr("hidden",false);
                        $('#authUpload').attr("hidden",true);
                        $('#pauseUpload').attr("hidden",true);
                        $('#resumeUpload').attr("hidden",true);

                        let getVideoUrl =  '/getVideoUrl?videoId='+ uploadInfo.videoId;
                        $.get(getVideoUrl, function (data) {
                            videoURL = data[0].playURL;
                            $("#videoPlay").attr("src",videoURL);
                            $("#notice-add-myvideo").val(videoURL);
                        },'json')
                    },
                    // 文件上传失败
                    onUploadFailed: function (uploadInfo, code, message) {
                        $('#status').text('文件上传失败!')
                    },
                    // 取消文件上传
                    onUploadCanceled: function (uploadInfo, code, message) {
                        $('#status').text('文件上传已暂停!')
                    },
                    // 文件上传进度，单位：字节, 可以在这个函数中拿到上传进度并显示在页面上
                    onUploadProgress: function (uploadInfo, totalSize, progress) {
                        let progressPercent = Math.ceil(progress * 100)
                        element.progress('videoProgress',progressPercent+'%');
                        $('#auth-progress').text(progressPercent)
                        $('#status').text('进度...'+progressPercent+'%')
                    },
                    // 上传凭证超时
                    onUploadTokenExpired: function (uploadInfo) {
                        // 上传大文件超时, 如果是上传方式一即根据 UploadAuth 上传时
                        // 需要根据 uploadInfo.videoId 调用刷新视频上传凭证接口(https://help.aliyun.com/document_detail/55408.html)重新获取 UploadAuth
                        // 然后调用 resumeUploadWithAuth 方法, 这里是测试接口, 所以我直接获取了 UploadAuth
                        $('#status').text('文件上传超时!')
                        let refreshUrl =  '/refreshAuth?videoId=' + uploadInfo.videoId
                        $.get(refreshUrl, function (data) {
                            let uploadAuth = data.uploadAuth
                            uploader.resumeUploadWithAuth(uploadAuth)
                        }, 'json')
                    },
                    // 全部文件上传结束
                    onUploadEnd: function (uploadInfo) {
                        $('#status').text('文件上传完毕!')
                    }
                })
                return uploader
            }

            let uploader = null

            $('#fileUpload').on('change', function (e) {
                $("#authUpload").attr("hidden",false);
                $("#pauseUpload").attr("hidden",false);
                let file = e.target.files[0]
                if (!file) {
                    febs.alert.warn("请先选择需要上传的文件!")
                    return
                }

                var fileName = file.name.substring(file.name.lastIndexOf(".") ).toLowerCase();
                title = file.name.substring(0,file.name.lastIndexOf("."));
                suffix = fileName;
                if (fileName !== ".mp4" && fileName !== ".M3U8" && fileName !== ".FLV" && fileName !== ".MKV") {
                    febs.alert.warn("请选择MP4、M3U8、FLV、MKV4格式文件上传！");
                    e.target.value ="";
                    return
                }
                let userData = '{"Vod":{}}'
                if (uploader) {
                    uploader.stopUpload()
                    $('#auth-progress').text('0')
                    $('#status').text("")
                }
                uploader = createUploader()
                // 首先调用 uploader.addFile(event.target.files[i], null, null, null, userData)
                uploader.addFile(file, null, null, null, userData)
                $('#authUpload').attr('disabled', false)
                $('#pauseUpload').attr('disabled', true)
                $('#resumeUpload').attr('disabled', true)
            })

            // 第一种方式 UploadAuth 上传
            $('#authUpload').on('click', function () {
                // 然后调用 startUpload 方法, 开始上传
                if (uploader !== null) {
                    uploader.startUpload()
                    $("#videoProgress").attr('hidden',false);
                    $('#authUpload').attr('disabled', true)
                    $('#pauseUpload').attr('disabled', false)
                }
            })

            // 暂停上传
            $('#pauseUpload').on('click', function () {
                if (uploader !== null) {
                    uploader.stopUpload()
                    $('#resumeUpload').attr('disabled', false)
                    $('#pauseUpload').attr('disabled', true)
                    $("#pauseUpload").attr("hidden",false);
                    $("#resumeUpload").attr("hidden",false);
                }
            })

            $('#resumeUpload').on('click', function () {
                if (uploader !== null) {
                    uploader.startUpload()
                    $('#resumeUpload').attr('disabled', true)
                    $('#pauseUpload').attr('disabled', false)
                    $("#pauseUpload").attr("hidden",false);
                    $("#resumeUpload").attr("hidden",false);
                }
            })

            // 查看文件
            $('#showFile').on('click', function () {
                console.log("ddddddddddddddd");
                console.log("file", $("#notice-add-myfile").val());
                if ($("#notice-add-myfile").val() != null && $("#notice-add-myfile").val() != "" && ($("#notice-add-myfile").val().indexOf('.txt') != -1 || $("#notice-add-myfile").val().indexOf('.pdf') != -1)){
                    layer.open({
                        type: 2
                        ,title: '查看文件' //不显示标题栏
                        ,closeBtn: 1
                        ,area: ['60%', '78%']
                        ,shade: 0.8
                        ,btn: ['确定']
                        ,btnAlign: 'r'
                        ,moveType: 1 //拖拽模式，0或者1
                        ,content: $("#notice-add-myfile").val()
                        ,maxmin:true

                    });
                }else if($("#notice-add-myfile").val() != null && $("#notice-add-myfile").val() != "" && ($("#notice-add-myfile").val().indexOf('.txt') == -1 && $("#notice-add-myfile").val().indexOf('.pdf') == -1))
                {
                    window.open($("#notice-add-myfile").val());
                }
                else {
                    layer.msg('暂未发现文件！')
                    console.log("ddddddddddddddd");
                }
            })
        })

    });
</script>